<!--#include file="p1.asp" -->
<%
Dim File,F,qes,retf
Easp.Upload.SavePath = "./upload"
If Easp.Upload.GetData Then
    For Each File In Easp.Upload.Files("-1")
        Set F = Easp.Upload.Save(File,0,True)
        If F.Succeed Then 
			qes=F.FileName
        End If 
    Next
End If
if qes<>"" then
	retf="{'code': 0  ,'msg': '[dy:msg]','data': {'src': 'http://cdn.layui.com/123.jpg'}}"
	retf=replace(retf,"[dy:msg]",qes)
	echo replace(retf,"'","""")
end if

Function qes2dbt()
	dim rs,sql,field0,i,ret,w
	dim line,modret,arr(15)
	dim tmp
	for i=0 to 14 
		arr(i)=cstr(i)
	next 
line=0
modret=0
w=" tn={tn} and dbName={dbName} "
Set rs = Easp.Db.Sel("select * from [ti0] where "&w&" order by id ")'
s11 "select prj_id from v_prj_u_t where  tn={tn} and prn={dbName}",""
Do While Not rs.EOF
	line=line+1
	modret = line \ 248
	modret=modret+1
	if arr(modret) = cstr(modret) then 
		vas "tmp",val("tn")  & "_" & val("prj_id") & "_" & cstr(modret)
		ret= Easp.Db.Upd ("[prj_table]","f1={tmp}","tn={tn} and prj_id={prj_id}")    	
		ret = Easp.Db.Exec("DROP TABLE "& val("tmp")) 
		sql = "CREATE TABLE ["& val("tmp") &"] ("
		arr(modret)= sql
		arr(modret)=arr(modret)& " id AUTOINCREMENT PRIMARY KEY,"
		arr(modret) = arr(modret) & " [cs] varchar(6)"& ","
		if modret > 1 then
			' arr(modret)=arr(modret) & "id AUTOINCREMENT PRIMARY KEY"
			' arr(modret)=arr(modret) & ",[NUMB] varchar(30),"
		end if
	end if

	field0=trim(rs("fld"))
	if field0="id" then
		' arr(modret)=arr(modret)& " id AUTOINCREMENT PRIMARY KEY,"
	end if

	' ret= easp.db.upd("bi0","tn=tn+'"&cstr(modret)+"'","fld='"& field0 &"' and "& w )
	
	if (instr(field0,"blank")>0 or (field0="id")) then
	else
		arr(modret) = arr(modret) & "[" & field0 & "] " & " varchar(60)"& ","
	end if
    rs.MoveNext
Loop
	
for i= 0 to ubound(arr)	
	if len(arr(i))>10 then
		sql=delLasts(arr(i))& ")"
		ret = Easp.Db.Exec(sql)		
		' sql="Create INDEX idx_" & cstr(i)  &  " ON " & val("tn") & cstr(i) & " (NUMB)"'UNIQUE
		' ret = Easp.Db.Exec(sql)		
	end if
next
End Function


Function delLasts(txt)
	txt=left(txt,len(txt)-1)
	delLasts=txt
End Function

Function m1()
dim fs,f,txt,mystr,i
dim head,tail,tail1,tail0,regEx,sql
dim line,ret,blank

set fs=Server.CreateObject("Scripting.FileSystemObject") 
Set f=fs.OpenTextFile(Server.MapPath("upload\" & val("qes")), 1)
line=0
blank=0
do while f.AtEndOfStream = false
	line=line+1
	txt=f.ReadLine
	if line=1 then
		' easp.var("tn")=txt
		Easp.Db.Del "ti0", "tn={tn}"
		' Easp.Db.Del "ti0", "dbName={dbName}"
	end if
    head=""
	tail=""

	easp.var("fld")=""
	easp.var("colName")=""
	easp.var("mm1")=""
	easp.var("regu1")=""
	
	if RegExpTest2("#+\.?#*", txt)<>"" then
		regEx="#+\.?#*"

		mystr=split(RegExpTest2(regEx, txt),"|") 
		tail= mid(txt,cint(mystr(0)))
		head=mid(txt,1,cint(mystr(0))-1)
		m2(head)
		tail0=mystr(1)
		tail1=replace(tail,tail0,"")

		easp.var("mm1")=tail1
		easp.var("regu1")=tail0
	elseif RegExpTest2("\_+", txt)<>"" then
		regEx="\_+"

		mystr=split(RegExpTest2(regEx, txt),"|") 
		tail= mid(txt,cint(mystr(0)))
		head=mid(txt,1,cint(mystr(0))-1)
		m2(head)
		tail0=mystr(1)
		tail1=trim(ReplaceTest(tail,regEx,""))

		easp.var("mm1")=tail1
		easp.var("regu1")=tail0
	elseif RegExpTest2("<\S+>", txt)<>"" then
		regEx="<\S+>"

		mystr=split(RegExpTest2(regEx, txt),"|") 
		tail= mid(txt,cint(mystr(0)))
		head=mid(txt,1,cint(mystr(0))-1)
		m2(head)
		tail0=mystr(1)
		tail1=trim(ReplaceTest(tail,regEx,""))
	
		easp.var("mm1")=tail1
		easp.var("regu1")=tail0
	else
		blank=blank+1
		easp.var("fld")="blank"& cstr(blank)
		easp.var("mm1")=txt
	end if
	
	vas "fld",ReplaceTest(val("fld"),"[\s+]","")
	vas "colName",ReplaceTest(val("colName"),"[\s+]","")
	vas "mm1",ReplaceTest(val("mm1"),"[\s+]","")
	vas "regu1",ReplaceTest(val("regu1"),"[\s+]","")
	
	sql=cr("ti0","fld,colName,mm1,regu1,tn,dbName") 
	Easp.Db.Exec(sql)
loop
f.Close
Set f=Nothing
Set fs=Nothing
End Function

Function m2(strng) 
	dim temp,head,tail
	temp=split(RegExpTest2("\s+",strng),"|") 
	head=mid(strng,1,cint(temp(0))+1)
	tail=mid(strng,cint(temp(0))+1)
	easp.var("fld")=head
	easp.var("colName")=tail
End Function
%>